package com.gzz.orchid.context.infrastructure.definition;

import com.gzz.orchid.common.core.support.IBaseEnum;

/**
 * 交易类型枚举
 * @author higmd
 */

public enum TradeType implements IBaseEnum {
    NORMAL(1,"常规"),
    GROUP(2,"团购"),
    SECKILL(3,"秒杀"),
    GIFT(4,"赠送");

    private final int code;
    private final String text;

    TradeType(int code, String text) {
        this.code = code;
        this.text = text;
    }

    public static TradeType parse(int val) {
        for (TradeType e : TradeType.values()) {
            if (e.code == val) {
                return e;
            }
        }
        throw new IllegalArgumentException("Invalid TradeType value: " + val);
    }

    public static TradeType of(String name) {
        return Enum.valueOf(TradeType.class, name);
    }

    @Override
    public Integer getValue() {
        return code;
    }

    @Override
    public String getLabel() {
        return text;
    }
}
